﻿// Decompiled with JetBrains decompiler
// Type: Netick.NetickLogger
// Assembly: Netick, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 6726ECA1-C773-4CF7-8952-E81B30D93B52
// Assembly location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.dll
// XML documentation location: D:\WorkSpaceDemo\UPM\NetickForUnity\Netick\Runtime\Netick.xml

#nullable disable
namespace Netick;

public static class NetickLogger
{
  internal static INetickLogger Logger;

  public static void SetLogger(INetickLogger logger) => NetickLogger.Logger = logger;

  public static void Log(object message)
  {
    if (NetickLogger.Logger == null)
      return;
    lock (NetickLogger.Logger)
      NetickLogger.Logger.Log(message);
  }

  public static void Log(NetickEngine engine, object message)
  {
    if (NetickLogger.Logger == null)
      return;
    lock (NetickLogger.Logger)
      NetickLogger.Logger.Log((object) $"[{engine.Name}] {message}");
  }

  public static void LogWarning(object message)
  {
    if (NetickLogger.Logger == null)
      return;
    lock (NetickLogger.Logger)
      NetickLogger.Logger.LogWarning(message);
  }

  public static void LogWarning(NetickEngine engine, object message)
  {
    if (NetickLogger.Logger == null)
      return;
    lock (NetickLogger.Logger)
      NetickLogger.Logger.LogWarning((object) $"[{engine.Name}] {message}");
  }

  public static void LogError(Entity obj, object message, object targetScript = null)
  {
    if (NetickLogger.Logger == null)
      return;
    lock (NetickLogger.Logger)
    {
      if (targetScript != null)
        NetickLogger.Logger.LogError((object) $"[{obj.Engine.Name}][Id: {obj.RawId}] {message}");
      else
        NetickLogger.Logger.LogException(message, targetScript);
    }
  }

  public static void LogError(NetickEngine engine, object message)
  {
    if (NetickLogger.Logger == null)
      return;
    lock (NetickLogger.Logger)
      NetickLogger.Logger.LogError((object) $"[{engine.Name}] {message}");
  }

  public static void LogError(object message, object targetScript = null)
  {
    if (NetickLogger.Logger == null)
      return;
    lock (NetickLogger.Logger)
    {
      if (targetScript == null)
        NetickLogger.Logger.LogError(message);
      else
        NetickLogger.Logger.LogException(message, targetScript);
    }
  }

  public static void Assert(bool condition, object message)
  {
    if (condition)
      return;
    NetickLogger.LogError((object) ("Assert Failed: " + message?.ToString()));
  }
}
